package cc.aliza.lib.mongo.core.decoder;

import cc.aliza.lib.mongo.core.annotations.Default;

import java.lang.reflect.Field;

/**
 * 『给时光以生命·给岁月以文明』
 *
 * @author Zhang Jing (byrdkm17@gmail.com).
 */
public abstract class AbstractDecoder implements Decoder {

    protected Field field;
    protected Object value;

    protected AbstractDecoder(Field field) {
        this.field = field;
    }

    @Override
    public boolean isNullField() {
        return value == null;
    }

    public String getFieldRealName(String name) {
        if (Default.NAME.equals(name)) {
            return field.getName();
        }
        return name;
    }
}
